﻿@model EnterpriseFund.Model.EnterpriseProp
@using System.Linq;
@{
    List<EnterpriseFund.Model.FinanceProp> financePropList = ViewData["financePropList"] != null ? (ViewData["financePropList"] as List<EnterpriseFund.Model.FinanceProp>) : new List<EnterpriseFund.Model.FinanceProp>();
    List<EnterpriseFund.Model.EnterpriseFinanceProp> enterpriseFinancePropList = ViewData["enterpriseFinancePropList"] != null ? (ViewData["enterpriseFinancePropList"] as List<EnterpriseFund.Model.EnterpriseFinanceProp>) : new List<EnterpriseFund.Model.EnterpriseFinanceProp>();
    Layout = null;
}
<!DOCTYPE html>
<html>
@Html.Partial("LoadPanelPartial")
<head>
    <title></title>
    @if (false)
    { 
        <script src="../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>

    @Html.DevExpress().GetStyleSheets(

        new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
)
    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
)


    <script type="text/javascript">
        function OK() {

            lpModal.Show();
            var codeNo = tbCodeNo.GetText();

            codeNo = ASPxClientUtils.Trim(codeNo);

            var clientchkfinancePropObj = ASPxClientCheckBoxList.Cast("chkfinanceProp");
            var chooseItemValues = clientchkfinancePropObj.GetSelectedValues();
            var str = "";
            for (var i = 0; i < chooseItemValues.length; i++) {
                str += chooseItemValues[i] + "%!^";
            }

            $.ajax({
                type: 'POST',
                url: rootPath + '/EnterpriseFinanceProp/EnterpriseFinancePropSave',
                data: { fEnterprisePropNo: codeNo, financeProplist: str, isAdd: '@ViewData["blcodeNo"]' },
                success: function (result) {
                    lpModal.Hide();
                    if (result == "exists") {
                        tbCodeNo.SetErrorText("编码已存在");
                        tbCodeNo.SetIsValid(false);
                    } else if (result == "ok") {
                        parent.codeOK();
                    } else if (result == "error") {
                        alert("保存失败");
                    }
                }
            });



        }


        function pd(codeNo, codeName) {
            var bl = true;
            if (null == codeNo || ASPxClientUtils.Trim(codeNo) == "") {
                tbCodeNo.SetErrorText("请填写资金性质编码");
                tbCodeNo.SetIsValid(false);
                bl = false;
            }
            if (null == codeName || ASPxClientUtils.Trim(codeName) == "") {
                tbCodeName.SetErrorText("请填写资金性质名称");
                tbCodeName.SetIsValid(false);
                bl = false;
            }

            return bl;
        }

    </script>

</head>
<body>
    <table class="tableFrom" width="100%">
        <tr>
            <th>
               企业性质编码:</th>
            <td>
                @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "tbCodeNo";
                   settings.Width = 180;

                   settings.ReadOnly = true;
                   
                   settings.Text = Model.FEnterprisePropNo;
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
            </td>
        </tr>
        <tr>
            <th>
                企业性质名称:</th>
            <td>
                @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "tbCodeName";
                   settings.Width = 180;
                   settings.ReadOnly = true;
                   settings.Text = Model.FEnterprisePropName;
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
            </td>
        </tr>
        <tr>
        <th>关联资金性质:</th>
        <td>@Html.DevExpress().CheckBoxList(settings1 =>
       {
           settings1.Name = "chkfinanceProp";
           settings1.Properties.EnableClientSideAPI = true;
           foreach (EnterpriseFund.Model.FinanceProp financeProp in financePropList)
           {
               List<EnterpriseFund.Model.EnterpriseFinanceProp> list = (from nm in enterpriseFinancePropList where nm.FFinancePropNo == financeProp.FFinancePropNo select nm).ToList();
               if (list.Count == 0)
               {
                   settings1.Properties.Items.Add(new ListEditItem() { Text = (financeProp.FFinancePropShortName == "" ? financeProp.FFinancePropName : financeProp.FFinancePropShortName), Value = financeProp.FFinancePropNo });
               }
               else
               {
                   settings1.Properties.Items.Add(new ListEditItem() { Text = (financeProp.FFinancePropShortName == "" ? financeProp.FFinancePropName : financeProp.FFinancePropShortName), Value = financeProp.FFinancePropNo, Selected = true });
               }
           }
           settings1.Properties.RepeatColumns = 3;

       }).GetHtml()</td>
        </tr>
       @* <tr>
            <td colspan="2">
                @Html.DevExpress().Button(settings =>
              {
                  settings.Name = "btnOK";
                  settings.Text = "确定";
                  settings.ControlStyle.CssClass = "left";
                  settings.ClientSideEvents.Click = "OK";
              }).GetHtml()
                @Html.DevExpress().Button(settings =>
              {
                  settings.Name = "btnCancel";
                  settings.Text = "取消";
                  settings.CausesValidation = false;
                  settings.ControlStyle.CssClass = "left";
                  settings.ClientSideEvents.Click = "function(){parent.codeCancel();}";
              }).GetHtml()
            </td>
        </tr>*@
    </table>

    <script>
        lp.Hide();
    </script>

</body>
</html>
